﻿using System;
using System.Collections.Generic;
using FrontRoomCheck.Model;
using FrontRoomCheck.Utiltiy;
using ModelCheckUtility.ModelLayer;

namespace FrontRoomCheck.SpecialUse
{
	public class FrontRoomCheck_CmdFrontRoomFind : IFrontRoomCheck<FrontRoomPacker>, IPackerCheck<FrontRoomPacker>, IBase<FrontRoomPacker>
	{
		public FrontRoomCheck_CmdFrontRoomFind()
		{
			this.rules = XmlManger.GetTypeXmlValue();
		}

		private bool doCheckFrontChamberType(FrontRoomPacker input)
		{
			bool flag = true;
			List<int> list = new List<int>();
			if (input.bIsNameMatch)
			{
				return true;
			}
			foreach (FrontChamberTypeRule frontChamberTypeRule in this.rules)
			{
				flag = true;
				for (int i = 0; i < frontChamberTypeRule.TypeRule.Count; i++)
				{
					list.Add(frontChamberTypeRule.TypeRule[StaticRescource.TypeArrtibuteNames[i]]);
				}
				flag = (input.thisDoorNum.StairDoor == list[0] && input.thisDoorNum.FireProogDoor == list[1] && input.thisDoorNum.FireLadderDoor == list[2] && flag);
				if (flag)
				{
					input.thisAreaOrSide.FrontRoomType = frontChamberTypeRule.name;
					break;
				}
				list.Clear();
			}
			return flag;
		}

		public List<FrontRoomPacker> CheckPackers(List<FrontRoomPacker> input, params object[] otherValues)
		{
			List<FrontRoomPacker> list = new List<FrontRoomPacker>();
			foreach (FrontRoomPacker frontRoomPacker in input)
			{
				if (this.doCheckFrontChamberType(frontRoomPacker) || frontRoomPacker.IsFrontRoom)
				{
					list.Add(frontRoomPacker);
				}
			}
			return list;
		}

		private List<FrontChamberTypeRule> rules = new List<FrontChamberTypeRule>();
	}
}
